// GxPositionEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "SpeedOrder.h"
#include "GxPositionEventSink.h"
#include "wp2_i_5.c"
#include "OrderManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxPositionEventSink

IMPLEMENT_DYNCREATE(GxPositionEventSink, CCmdTarget)

GxPositionEventSink::GxPositionEventSink()
{
	EnableAutomation();
	m_pOrderMgr = NULL;
}

GxPositionEventSink::~GxPositionEventSink()
{
}


void GxPositionEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxPositionEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxPositionEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxPositionEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxPositionEventSink)
	DISP_FUNCTION(GxPositionEventSink, "OnNewPosition", OnNewPosition, VT_EMPTY, VTS_DISPATCH)
	DISP_FUNCTION(GxPositionEventSink, "OnPositionUpdated", OnPositionUpdated, VT_EMPTY, VTS_DISPATCH)
	DISP_FUNCTION(GxPositionEventSink, "OnEvalPLUpdated", OnEvalPLUpdated, VT_EMPTY, VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxPositionEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {4028471C-AA83-44E6-AC78-CCD87AAFED50}
//static const IID IID_IGxPositionEventSink =
//{ 0x4028471c, 0xaa83, 0x44e6, { 0xac, 0x78, 0xcc, 0xd8, 0x7a, 0xaf, 0xed, 0x50 } };

BEGIN_INTERFACE_MAP(GxPositionEventSink, CCmdTarget)
	INTERFACE_PART(GxPositionEventSink, DIID_IGxPositionEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxPositionEventSink message handlers

void GxPositionEventSink::OnNewPosition(LPDISPATCH a_GxPosition) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnNewPosition(a_GxPosition);
}

void GxPositionEventSink::OnPositionUpdated(LPDISPATCH a_GxPosition) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnPositionUpdated(a_GxPosition);
}

void GxPositionEventSink::OnEvalPLUpdated(LPDISPATCH a_GxPosition) 
{
	// TODO: Add your dispatch handler code here
	if (m_pOrderMgr)
		m_pOrderMgr->OnEvalPLUpdated(a_GxPosition);
}
 